<?php

namespace app\yunda\validate;
use think\Validate;
use think\Db;

/**
 * 寄签到验证
 * @package app\yunda\validate
 */
class Qiandao extends Validate
{
    //定义验证规则
    protected $rule = [
        'openid|微信id' => 'require|checkOpenid',
       // 'qd_time|签到时间' => 'require|checkQdTime',
    ];

    //定义验证提示
    protected $message = [
    ];

    protected function checkOpenid($value,$rule)
    {
        $row=Db::table('dp_yd_user')->where('openid',$value)->find();
        if(empty($row)){
            return $rule='用户不存在';
        }
        return $rule=true;
    }

//    protected function checkQdTime($value,$rule,$data)
//    {
//        $row=Db::table('dp_yd_qiandao')
//            ->whereTime('create_time','d')
//            ->where(['openid'=>$data['openid']])
//            ->find();
//        if(empty($row)){
//            return $rule=true;
//        }
//        return $rule='您今天已经签到';
//    }
}
